package org.webbase.system.pojo;

import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Journal {
	private String levelName;      	// 日志级别名称
	private String dateLog;			// 日期
	private String fileSize;
	private String path;
	private String baseName;
	private String content;
	
	public Journal(){
		
	}
	
	public Journal(File file){
		this.baseName = file.getName();
		this.path = file.getPath();
		String[] sp = this.baseName.split("\\.");
		this.fileSize = Long.toString(file.length());
		if(sp.length >= 2 && "log".equals(sp[sp.length-1]) ){
			this.levelName = sp[0];
			if("log".equals(sp[1])){
				DateFormat df6 = new SimpleDateFormat("yyyy-MM-dd"); 
				Date date = new Date(); 
				this.dateLog = df6.format(date);
			}else{
				this.dateLog = sp[1];
			}
		}
	}
	
	
	public String getFileSize() {
		return fileSize;
	}

	public void setFileSize(String fileSize) {
		this.fileSize = fileSize;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getBaseName() {
		return baseName;
	}

	public void setBaseName(String baseName) {
		this.baseName = baseName;
	}


	public String getLevelName() {
		return levelName;
	}
	
	public void setLevelName(String levelName) {
		this.levelName = levelName;
	}
	
	public String getDateLog() {
		return dateLog;
	}
	
	public void setDateLog(String dateLog) {
		this.dateLog = dateLog;
	}
	
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String toString(){
		StringBuilder sb = new StringBuilder();
		sb.append("{").append(this.baseName).append(",").append(this.path).append("}");
		return sb.toString();
	}
	
}
